package com.heima.service.impl;

import com.heima.mapper.NodeMapper;
import com.heima.mapper.TypeMapper;
import com.heima.mapper.VmMapper;
import com.heima.pojo.Business;
import com.heima.pojo.Node;
import com.heima.pojo.Region;
import com.heima.pojo.Vm;
import com.heima.pojo.dto.PagingQueryDTO;
import com.heima.pojo.vo.PagingVO;
import com.heima.service.VmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VmServicelmpl implements VmService {
    @Autowired
    private VmMapper vmMapper;
    @Autowired
    private NodeMapper nodeMapper;
    @Autowired
    private TypeMapper typeMapper;
    /**设备搜索
     * @param pagingQueryDTO
     * @return
     */
    @Override
    public PagingVO slectVm(PagingQueryDTO pagingQueryDTO) {
        //查询设备
        List<Vm> vm = vmMapper.slectVm(pagingQueryDTO.getInnerCode());
        for (Vm vm1 : vm) {
            //查询关联区域的点位
            List<Node> node1 = nodeMapper.getRegion(vm1.getRegionId());
            Node node = node1.get(0);
            //根据查询id地区获取地区信息
            Region regionVO = nodeMapper.getRegionInfo(vm1.getRegionId());
            //查询商圈信息
            Business business = nodeMapper.getBusiness(node.getBusinessId() );
            //查询设备信息
//            typeMapper.slectType( vm1.getVmType())
            node.setRegion(regionVO);
            node.setBusinessType(business);
        }
return null;
    }
}
